package parserjc.jaccie;

import javax.swing.*;
import javax.swing.border.*;
import java.util.*;
import java.awt.*;

public class TestFenster extends JFrame {
    private JTextArea stack,values,history;
    public TestFenster() {
        super("TestFenster");
        getContentPane().setLayout(new GridLayout(1,3));
        JPanel leftPanel = new JPanel(new GridLayout(1,1,0,0));
        leftPanel.setBorder(new TitledBorder("Stack"));
        stack = new JTextArea();
        leftPanel.add(new JScrollPane(stack));
        getContentPane().add(leftPanel);
        JPanel middPanel = new JPanel(new GridLayout(1,1,0,0));
        middPanel.setBorder(new TitledBorder("Values"));
        values = new JTextArea();
        middPanel.add(new JScrollPane(values));
        getContentPane().add(middPanel);
        JPanel rightPanel = new JPanel(new GridLayout(1,1,0,0));
        rightPanel.setBorder(new TitledBorder("History"));
        history = new JTextArea();
        rightPanel.add(new JScrollPane(history));
        getContentPane().add(rightPanel);
		setSize(400,400);
		setVisible(true);
    }

    public void update(Vector stack, int stackPos,Vector values, Vector history) {
        String help = "";
		for (int i=0; i<stack.size(); i++) {
            if (i != 0) help += "\n";
            if (i == stackPos) help += "---------------\n";
            help += stack.elementAt(i);
        }
        this.stack.setText(help);
        help = "";
		for (int i=0; i<values.size(); i++) {
            if (i != 0) help += "\n";
            help += values.elementAt(i);
        }
        this.values.setText(help);
        help = "";
		for (int i=0; i<history.size(); i++) {
            if (i != 0) help += "\n";
            help += history.elementAt(i);
        }
        this.history.setText(help);
    }
}
